//
//  MyOrderViewController.m
//  wtshoppingcite
//
//  Created by TW on 14-10-24.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "MyOrderViewController.h"
#import "JVButton.h"
#import "NetServiseCommonData.h"
#import "OrderDetailCell.h"
#import "AppDelegate.h"
#import "OrderTableView.h"
#import "MyOrderModel.h"
#import "MyOrderItems.h"
#import "MyOrderDetailViewController.h"
#import "PayTableView.h"
#import "ShippedTableView.h"
#import "CompletionTableView.h"
#import "PaymentViewController.h"
#import "EvaluateViewController.h"
#import "OtherEvaluateViewController.h"

@interface MyOrderViewController ()<CustomTabItemViewDelegate,UITableViewEventsDelegate,OpertionOrderDetailTableView,OpertionCompletionTableView,OpertionShippedTableView,myOrderDetailDelegate>
{
    OrderTableView *orderTableView;
    PayTableView *payTableView;
    ShippedTableView *shippedTableView;
    CompletionTableView *completionTableView;
    NSString *pageNum;
    OtherEvaluateViewController *evaluateVC;
}
@property(strong,nonatomic)NSMutableArray *dataArray;
@property(strong,nonatomic)NSMutableArray *myOrderArray;

@property(strong,nonatomic)NSMutableArray *payArray;
@property(strong,nonatomic)NSMutableArray *payDetailArray;

@property(strong,nonatomic)NSMutableArray *shippedArray;
@property(strong,nonatomic)NSMutableArray *shippedDetailArray;

@property(strong,nonatomic)NSMutableArray *completionArray;
@property(strong,nonatomic)NSMutableArray *complDetailArray;

@end

@implementation MyOrderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setTitleView:@"我的订单"];
    
    self.tabItemView = [[CustomTabItemView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 45) type:TAB_ITEM_TYPE_DEFAULT];
    self.tabItemView.backgroundColor = COLOR_RGBA(245, 245, 245,1);
    self.tabItemView.delegate = self;
    self.tabItemView.orderModel = self.orderModel;
    [self.tabItemView initWithLineItemNames:@[@"待付款",@"已付款",@"已发货",@"交易完成"]];

    [self.view addSubview:self.tabItemView];
    
    //待付款
    orderTableView  = [[OrderTableView alloc]initWithFrame:CGRectMake(0, self.tabItemView.bottom, kWidth, kHeight - 64 - 45) style:UITableViewStylePlain];
    orderTableView.isNeedTorefresh = YES;
    orderTableView.eventsDelegate = self;
    orderTableView.myOrderDelegate = self;
    orderTableView.isMore = YES;
    [self.view addSubview:orderTableView];
    
    //已付款
    payTableView  = [[PayTableView alloc]initWithFrame:CGRectMake(0, self.tabItemView.bottom, kWidth, kHeight - 64 - 45) style:UITableViewStylePlain];
    payTableView.isNeedTorefresh = YES;
    payTableView.eventsDelegate = self;
    payTableView.isMore = YES;
    payTableView.hidden = YES;
    [self.view addSubview:payTableView];
   
    //已发货
    shippedTableView  = [[ShippedTableView alloc]initWithFrame:CGRectMake(0, self.tabItemView.bottom, kWidth, kHeight - 64 - 45) style:UITableViewStylePlain];
    shippedTableView.isNeedTorefresh = YES;
    shippedTableView.eventsDelegate = self;
    shippedTableView.shippedDelegate = self;
    shippedTableView.isMore = YES;
    shippedTableView.hidden = YES;
    [self.view addSubview:shippedTableView];

    //交易完成
    completionTableView  = [[CompletionTableView alloc]initWithFrame:CGRectMake(0, self.tabItemView.bottom, kWidth, kHeight - 64 - 45) style:UITableViewStylePlain];
    completionTableView.isNeedTorefresh = YES;
    completionTableView.eventsDelegate = self;
    completionTableView.isMore = YES;
    completionTableView.hidden = YES;
    completionTableView.completionDelegate = self;
    [self.view addSubview:completionTableView];
    
    _dataArray = [[NSMutableArray alloc]initWithCapacity:1];
    _myOrderArray = [[NSMutableArray alloc]initWithCapacity:1];

    _payArray = [[NSMutableArray alloc]initWithCapacity:1];
    _payDetailArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    _shippedArray = [[NSMutableArray alloc]initWithCapacity:1];
    _shippedDetailArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    _completionArray = [[NSMutableArray alloc]initWithCapacity:1];
    _complDetailArray = [[NSMutableArray alloc]initWithCapacity:1];
    
    pageNum = @"0";
    
    [self pullDown:orderTableView];
    [self pullDown:payTableView];
    [self pullDown:shippedTableView];
    [self pullDown:completionTableView];
    
    // Do any additional setup after loading the view.
}


#pragma mark  eventsDelegate
- (void)pullUp:(BaseTableView *)baseTableView{
    
    if (baseTableView == orderTableView) {
        [self getMyOrderWithData:YES];
    }else if (baseTableView == payTableView){
        [self getPayWithData:YES];
    }else if (baseTableView == shippedTableView){
        [self getShippedWithData:YES];
    }else if (baseTableView == completionTableView){
        [self getCompletionWithData:YES];
    }
    
}

- (void)pullDown:(BaseTableView *)baseTableView{
    
    pageNum = @"0";
    if (baseTableView == orderTableView) {
        [self getMyOrderWithData:NO];
    }else if (baseTableView == payTableView){
        [self getPayWithData:NO];
    }else if (baseTableView == shippedTableView){
        [self getShippedWithData:NO];
    }else if (baseTableView == completionTableView){
        [self getCompletionWithData:NO];
    }
    
}

#pragma mark getMyOrderWithData 待付款
-(void)getMyOrderWithData:(BOOL)isMore{
    
    NSString *userId = [[RegisterHelper shareHelper]userId];
    NSString *page = pageNum;
    NSString *pageSize = @"10";
    
    __weak MyOrderViewController *weak_self = self;
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
   
    SetValueForKey(listDic, userId, @"userId");
    SetValueForKey(listDic, page, @"page");
    SetValueForKey(listDic, pageSize, @"pageSize");
    SetValueForKey(listDic, @"1", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:orderTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderList
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         [orderTableView doneLoadingTableViewData];
                        [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         request.requestCache = YES;
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                             
                             NSArray *list = [responseDic objectForKey:@"list"];
                             self.orderModel.news = [NSString stringWithFormat:@"%d",list.count];
                             
                            [self.tabItemView refreshBugeNum:self.orderModel.news indexButton:10];
                             
                             if (list.count < 10) {
                                 orderTableView.isMore = NO;
                             }else{
                                 orderTableView.isMore = YES;
                                 
                                 int currentPage = [pageNum intValue];
                                 pageNum = [NSString stringWithFormat:@"%d",currentPage+1];
                                 
                             }
                             if (!isMore) {
                                 [_dataArray removeAllObjects];
                                 [_myOrderArray removeAllObjects];
                             }
                             
                             for(NSDictionary* dic in list){
                                 [_dataArray addObject:dic];
                                 NSArray* orderItems = [dic objectForKey:@"orderItems"];
                                 for(NSDictionary* dic in orderItems){
                                     [_myOrderArray addObject:dic];
                                 }
                             }
                            
                             orderTableView.data = _dataArray;
                            
                             
                         }
                         [orderTableView reloadData];
                     }];
}


#pragma mark getMyOrderWithData 已付款
-(void)getPayWithData:(BOOL)isMore{
    
    NSString *userId = [[RegisterHelper shareHelper]userId];
    NSString *page = pageNum;
    NSString *pageSize = @"10";
    
    __weak MyOrderViewController *weak_self = self;
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    
    SetValueForKey(listDic, userId, @"userId");
    SetValueForKey(listDic, page, @"page");
    SetValueForKey(listDic, pageSize, @"pageSize");
    SetValueForKey(listDic, @"4", @"statusId");
    
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:payTableView];
  
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderList
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         [payTableView doneLoadingTableViewData];
                          [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         request.requestCache = YES;
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                             
                             NSArray *list = [responseDic objectForKey:@"list"];
                             if (list.count < 10) {
                                 payTableView.isMore = NO;
                             }else{
                                 payTableView.isMore = YES;
                                 
                                 int currentPage = [pageNum intValue];
                                 pageNum = [NSString stringWithFormat:@"%d",currentPage+1];
                                 
                             }
                             if (!isMore) {
                                 [_payArray removeAllObjects];
                                 [_payDetailArray removeAllObjects];
                             }
                             
                             for(NSDictionary* dic in list){
                                 [_payArray addObject:dic];
                                 NSArray* orderItems = [dic objectForKey:@"orderItems"];
                                 for(NSDictionary* dic in orderItems){
                                     [_payDetailArray addObject:dic];
                                 }
                             }
                             
                             payTableView.data = _payDetailArray;
                         }
                         [payTableView reloadData];
                     }];
}



#pragma mark getShippedWithData 已发货
-(void)getShippedWithData:(BOOL)isMore{
    
    NSString *userId = [[RegisterHelper shareHelper]userId];
    NSString *page = pageNum;
    NSString *pageSize = @"10";
    
    __weak MyOrderViewController *weak_self = self;
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    
    SetValueForKey(listDic, userId, @"userId");
    SetValueForKey(listDic, page, @"page");
    SetValueForKey(listDic, pageSize, @"pageSize");
    SetValueForKey(listDic, @"8", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:shippedTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderList
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         [shippedTableView doneLoadingTableViewData];
                         [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         request.requestCache = YES;
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                             
                             NSArray *list = [responseDic objectForKey:@"list"];
                             self.orderModel.deliverds = [NSString stringWithFormat:@"%d",list.count];
                             [self.tabItemView refreshBugeNum:self.orderModel.deliverds indexButton:12];

                             if (list.count < 10) {
                                 shippedTableView.isMore = NO;
                             }else{
                                 shippedTableView.isMore = YES;
                                 
                                 int currentPage = [pageNum intValue];
                                 pageNum = [NSString stringWithFormat:@"%d",currentPage+1];
                                 
                                 
                             }
                             if (!isMore) {
                                 [_shippedArray removeAllObjects];
                                 [_shippedDetailArray removeAllObjects];
                             }
                             
                             for(NSDictionary* dic in list){
                                 [_shippedArray addObject:dic];
                                 NSArray* orderItems = [dic objectForKey:@"orderItems"];
                                 for(NSDictionary* dic in orderItems){
                                     [_shippedDetailArray addObject:dic];
                                 }
                             }
                             
                             shippedTableView.data = _shippedArray;
                         }
                         [shippedTableView reloadData];
                     }];
}


#pragma mark getCompletionWithData 交易完成
-(void)getCompletionWithData:(BOOL)isMore{
    
    NSString *userId = [[RegisterHelper shareHelper]userId];
    NSString *page = pageNum;
    NSString *pageSize = @"10";
    
    __weak MyOrderViewController *weak_self = self;
    NSMutableDictionary *listDic = [NSMutableDictionary dictionary];
    
    SetValueForKey(listDic, userId, @"userId");
    SetValueForKey(listDic, page, @"page");
    SetValueForKey(listDic, pageSize, @"pageSize");
    SetValueForKey(listDic, @"32", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:shippedTableView];
 
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderList
                             andHttpMethod:@"POST"
                             andParameters:listDic
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         [completionTableView doneLoadingTableViewData];
                      [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         request.requestCache = YES;
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             DLog(@"成功数据:%@",responseDic);
                             
                           
                             
                             NSArray *list = [responseDic objectForKey:@"list"];
                            
                             self.orderModel.finisheds = [NSString stringWithFormat:@"%d",list.count];
                            [self.tabItemView refreshBugeNum:self.orderModel.finisheds indexButton:13];
                             
                             if (list.count < 10) {
                                 completionTableView.isMore = NO;
                             }else{
                                 completionTableView.isMore = YES;
                                 
                                 int currentPage = [pageNum intValue];
                                 pageNum = [NSString stringWithFormat:@"%d",currentPage+1];
                                 
                             }
                             if (!isMore) {
                                 [_completionArray removeAllObjects];
                                 [_complDetailArray removeAllObjects];
                             }
                             
                             for(NSDictionary* dic in list){
                                 [_completionArray addObject:dic];
                                 NSArray* orderItems = [dic objectForKey:@"orderItems"];
                                 for(NSDictionary* dic in orderItems){
                                     [_complDetailArray addObject:dic];
                                 }
                             }
                             
                             completionTableView.data = _completionArray;
                         }
                         [completionTableView reloadData];
                     }];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    ;
}


- (void)viewWillDisappear:(BOOL)animated
{
    
    [super viewWillDisappear:animated];
    
    
}

#pragma mark CustomTabItemViewDelegate
-(void)tabItemSelectedAtIndex:(int)index tabButton:(UIButton *)button tabItem:(CustomTabItemView *)view{
    
    if (index == 0) {
        
        orderTableView.hidden = NO;
        payTableView.hidden = YES;
        shippedTableView.hidden = YES;
        completionTableView.hidden = YES;
        
        [self pullDown:orderTableView];
        
    }else if (index == 1){
        
        orderTableView.hidden = YES;
        payTableView.hidden = NO;
        shippedTableView.hidden = YES;
        completionTableView.hidden = YES;

        
        [self pullDown:payTableView];
      
    }else if (index == 2){
        
        orderTableView.hidden = YES;
        payTableView.hidden = YES;
        shippedTableView.hidden = NO;
        completionTableView.hidden = YES;

        [self pullDown:shippedTableView];
        
    }else if (index == 3){
        
        orderTableView.hidden = YES;
        payTableView.hidden = YES;
        shippedTableView.hidden = YES;
        completionTableView.hidden = NO;
        
        [self pullDown:completionTableView];
       
    }
}



#pragma mark basetableView
-(void)basetableView:(BaseTableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (tableView == orderTableView) {
        
        MyOrderDetailViewController *myOrderDVC = [[MyOrderDetailViewController alloc]init];
        MyOrderItems *myOrderItems = [[MyOrderItems alloc]initWithMyOrderItemInfo:[_myOrderArray objectAtIndex:indexPath.row]];
        myOrderDVC.delegate = self;
        myOrderDVC.myOrderItems =myOrderItems;
        MyOrderModel *myOrderModel = [[MyOrderModel alloc]initWithMyOrderInfo:[_dataArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderModel = myOrderModel;

        myOrderDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:myOrderDVC animated:YES];
        
    }else if (tableView == payTableView){
        
        MyOrderDetailViewController *myOrderDVC = [[MyOrderDetailViewController alloc]init];
        MyOrderItems *myOrderItems = [[MyOrderItems alloc]initWithMyOrderItemInfo:[_payDetailArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderItems =myOrderItems;
         myOrderDVC.delegate = self;
        MyOrderModel *myOrderModel = [[MyOrderModel alloc]initWithMyOrderInfo:[_payArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderModel = myOrderModel;
        
        myOrderDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:myOrderDVC animated:YES];
        
    }else if (tableView == shippedTableView){
        
        MyOrderDetailViewController *myOrderDVC = [[MyOrderDetailViewController alloc]init];
        MyOrderItems *myOrderItems = [[MyOrderItems alloc]initWithMyOrderItemInfo:[_shippedDetailArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderItems =myOrderItems;
         myOrderDVC.delegate = self;
        MyOrderModel *myOrderModel = [[MyOrderModel alloc]initWithMyOrderInfo:[_shippedArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderModel = myOrderModel;
        
        myOrderDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:myOrderDVC animated:YES];
        
    }else if (tableView == completionTableView){
        
        MyOrderDetailViewController *myOrderDVC = [[MyOrderDetailViewController alloc]init];
        MyOrderItems *myOrderItems = [[MyOrderItems alloc]initWithMyOrderItemInfo:[_complDetailArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderItems =myOrderItems;
         myOrderDVC.delegate = self;
        MyOrderModel *myOrderModel = [[MyOrderModel alloc]initWithMyOrderInfo:[_completionArray objectAtIndex:indexPath.row]];
        myOrderDVC.myOrderModel = myOrderModel;
        
        myOrderDVC.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:myOrderDVC animated:YES];
        
    }
    
}

//待付款 －－下单
-(void)payOrderDetailTableView:(MyOrderModel *)data{
    
     MyOrderItems *myOrderItems = [[MyOrderItems alloc]initWithMyOrderItemInfo:[data.orderItems objectAtIndex:0]];
    
    //调下定单接口
    PaymentViewController *paymentVC =[[PaymentViewController alloc]init];
    paymentVC.hidesBottomBarWhenPushed = YES;
    paymentVC.type = NSShoppingPayForStyle;
    paymentVC.orders =data.orderId;
    
    NSString *totalPrice = [NSString stringWithFormat:@"%.2f",[myOrderItems.count integerValue]*[myOrderItems.salePrice floatValue]];
    paymentVC.totalPrice = totalPrice;
    
    [self.navigationController pushViewController:paymentVC animated:YES];
}

//待付款 －－取消下单
-(void)cancleOrderDetailTableView:(MyOrderModel *)data{

    //调取消定单接口，在回调里面进行数据刷新表格数据
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    SetValueForKey(params, [RegisterHelper shareHelper].userId, @"userId");
    SetValueForKey(params, data.orderId, @"orderId");
    SetValueForKey(params, @"2", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:orderTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderUpdate
                             andHttpMethod:@"POST"
                             andParameters:params
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                            [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                            
                             DLog(@"成功数据:%@",responseDic);
                             pageNum = @"0";
                             [self getMyOrderWithData:NO];
                            
                             
                              [orderTableView reloadData];
                         }
                         
                         }];
}

//已发货 －－确认收货
-(void)finshShippedTableView:(MyOrderModel *)data{
    
    //调取消定单接口，在回调里面进行数据刷新表格数据
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    SetValueForKey(params, [RegisterHelper shareHelper].userId, @"userId");
    SetValueForKey(params, data.orderId, @"orderId");
    SetValueForKey(params, @"32", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:shippedTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderUpdate
                             andHttpMethod:@"POST"
                             andParameters:params
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                         [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             
                             DLog(@"成功数据:%@",responseDic);
                             pageNum = @"0";
                             [self getShippedWithData:NO];
                             
                             [shippedTableView reloadData];
                         }
                     }];

}

//交易完成 －－删除订单
-(void)cancleCompletionTableView:(MyOrderModel*)data{
    
    
    //调取消定单接口，在回调里面进行数据刷新表格数据
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    SetValueForKey(params, [RegisterHelper shareHelper].userId, @"userId");
    SetValueForKey(params, data.orderId, @"orderId");
    SetValueForKey(params, @"64", @"statusId");
    
    [self dismissLoadImageView];
    [self showLoadImageView:self.view subview:completionTableView];
    [NetWorkService byRequestWithAPIPrefix:kBaseAppUrl
                              andAPISuffix:kOrderUpdate
                             andHttpMethod:@"POST"
                             andParameters:params
                           andRequestCache:NO
                            andUseParamDic:YES
                       andPostDataEncoding:MKNKPostDataEncodingTypeJSON
                     andRequestFinishBlock:^(BYRequest *request, BYResponse *response) {
                            [self performSelector:@selector(dismissLoadImageView) withObject:nil afterDelay:1.0];
                         if (response.isError) {
                             
                             DLog(@"error %@",response.errorMessage);
                             
                         }else{
                             
                             NSDictionary *responseDic = request.responseJSON;
                             
                             DLog(@"成功数据:%@",responseDic);
                             pageNum = @"0";
                             [self getCompletionWithData:NO];
                             
                             [completionTableView reloadData];
                         }
                     }];
    
}


#pragma mark 待付款
-(void)payOrderAction:(MyOrderModel *)myOrderModel{
    [self payOrderDetailTableView:myOrderModel];
}
#pragma mark 取消订单
-(void)cancelOrderAction:(MyOrderModel *)myOrderModel{
    [self cancleOrderDetailTableView:myOrderModel];
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark 评价订单
-(void)commentOrderAction:(MyOrderModel *)myOrderModel{
    
    [self payCompletionTableView:myOrderModel];
}
#pragma mark 删除订单
-(void)canceledOrderAction:(MyOrderModel *)myOrderModel{
     [self cancleCompletionTableView:myOrderModel];
}
#pragma mark 确认收货
-(void)confirmAction:(MyOrderModel *)myOrderModel{
    [self finshShippedTableView:myOrderModel];
}

//交易完成 －－评价
-(void)payCompletionTableView:(MyOrderModel*)data{
    
    
    evaluateVC = [[OtherEvaluateViewController alloc]initWithNibName:@"OtherEvaluateViewController" bundle:nil];
    evaluateVC.hidesBottomBarWhenPushed = YES;
    evaluateVC.myOrderModel = data;
    [self.navigationController pushViewController:evaluateVC animated:YES];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
